<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="/js-test-resources/js-test.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script type="text/javascript">
description("Make sure event handler called serially.");

window.jsTestIsAsync = true;

var ws = new WebSocket("ws://127.0.0.1:8880/send2");

ws.onopen = function()
{
    debug("Connected");
};

ws.onmessage = function(messageEvent)
{
    debug("Enter onmessage: " + messageEvent.data);
    // alert() will suspend/resume WebSocket.
    alert("message handled." + messageEvent.data);
    debug("Leave onmessage: " + messageEvent.data);
};

ws.onclose = function()
{
    debug("Closed");
    finishJSTest();
};

debug("alert will suspend/resume WebSocket.");
alert("waiting for open");
debug("onopen should fire later.");
</script>
</body>
</html>
